import router from './index';
import store from '@/store';
router.beforeEach(async(to, from, next) => {
  // 1111111111111111111
  // if(to.path === '/test') {
  //   next()
  //   return;
  // }
  // 1111111111111111111
  if(window.name === 'detailInfo') {
    next()
    return;
  }
	const hasToken = store.state.token; // 后续删除
  if(hasToken) {
    if(!store.state.permission) {
      await store.dispatch('getNewRoute')
      next({
        ...to,replace:true
      })
      return;
    } else {
      next();
    }
  } else {
    // 没有token
    if(to.path === '/login') {
      next();
    } else {
      next('/login');
    }
  }
})